package solution.pointer;

import java.util.Arrays;

/**
 * @author : wenchao.long
 * @date : Created in 2024-07-05 下午 10:34 周五
 * @description : 移动零
 * 		<a href="https://leetcode.cn/problems/move-zeroes/?envType=study-plan-v2&envId=top-100-liked">移动零</a>
 */
public class No283 {

	public static void moveZeroes(int[] nums) {
		if (nums.length == 1) {
			return;
		}
		int pt = 0;
		for (int i = 0; i < nums.length; ++i) {
			if (nums[i] != 0) {
				nums[pt++] = nums[i];
			}
		}
		for (int i = pt; i < nums.length; ++i) {
			nums[i] = 0;
		}
		System.out.println(Arrays.toString(nums));
	}

	public static void main(String[] args) {
		moveZeroes(new int[]{0, 1, 0, 3, 12});
	}
}
